<?php


Function is_maj($current)
{
	if (!is_administrator($_SESSION['uid']))
		return (-1);
		
	if (!($fd = @fopen("http://www.opendevtools.net/data/config/version.txt", 'r')))
		return (-1);
	
	$i = -1;
	while(!(FEOF($fd)))
	{
		$i++;
		$line = explode('=', fgets($fd));
		@$line = $line[1];
		$lines[$i] = $line;
	}
	fclose($fd);
	$maj = $lines[0];
	
	if ($i > -1)
	{
		$tmp_maj = explode('.', $maj);
		$tmp_cur = explode('.', $current);
		/*if ((int)$tmp_maj[0] > (int)$tmp_ver[0])
			return ($maj);
		elseif ((int)$tmp_maj[0] == (int)$tmp_ver[0])
		{
			if ((int)$tmp_maj[1] > (int)$tmp_ver[1])
				return ($maj);
			elseif ((int)$tmp_maj[1] == (int)$tmp_ver[1])
			{
				if ((int)$tmp_maj[2] > (int)$tmp_ver[2])
					return ($maj);
			}
		}*/
		$tcurrent = ((int)$tmp_cur[0] * 100) + ((int)$tmp_cur[1] * 10) + ((int)$tmp_cur[2] * 0.1);
		$tmaj = ((int)$tmp_maj[0] * 100) + ((int)$tmp_maj[1] * 10) + ((int)$tmp_maj[2] * 0.1);
		if ($tcurrent < $tmaj)
			return ($maj);
	}
	return (0);
}

Function edit_status($status)
{
	if (!is_administrator($_SESSION['uid']))
		return (-1);
		
	if (!($fd = fopen("../".$_SESSION['path_config_version'], 'r')))
		return (-1);
	$i = -1;
	while(!(FEOF($fd)))
	{
		$i++;
		$line = fgets($fd);
		if (preg_match('/\$status/', $line))
			$line = ' '.' $status = '.'"'.$status.'"'.';'."\n";
		$lines[$i] = $line;
	}
	fclose($fd);
	
	if (!($fd = fopen("../".$_SESSION['path_config_version'], 'w')))
		return (-1);
	$nb_lines = count($lines);
	$i = 0;
	while($i < $nb_lines)
	{
		fputs($fd, $lines[$i]);
		$i++;
	}
	fclose($fd);
	
	$_SESSION['status'] = $status;
	
	return (0);
}

Function edit_titles($title, $subtitle)
{
	if (!is_administrator($_SESSION['uid']))
		return (-1);
		
	if (!($fd = fopen("../".$_SESSION['path_config_default'], 'r')))
		return (-1);
	$i = -1;
	while(!(FEOF($fd)))
	{
		$i++;
		$line = fgets($fd);
		if (preg_match('/\$title/', $line))
			$line = '$title = '.'"'.$title.'"'.';'."\n";
		elseif (preg_match('/\$subtitle/', $line))
			$line = '$subtitle = '.'"'.$subtitle.'"'.';'."\n";
		$lines[$i] = $line;
	}
	fclose($fd);
	
	if (!($fd = fopen("../".$_SESSION['path_config_default'], 'w')))
		return (-1);
	$nb_lines = count($lines);
	$i = 0;
	while($i < $nb_lines)
	{
		fputs($fd, $lines[$i]);
		$i++;
	}
	fclose($fd);
	
	$_SESSION['title'] = $title;
	$_SESSION['subtitle'] = $subtitle;
	
	return (0);
}

?>